home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-09-30 | 46.7 KB | 1,681 lines |
- Newsgroups: comp.sources.misc
- subject: v08i084: libhoward portability library, part 6 of 9
- from: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
- Reply-To: howard@dahlbeck.ericsson.se (Howard Gayle)
-
- Posting-number: Volume 8, Issue 84
- Submitted-by: howard@dahlbeck.ericsson.se (Howard Gayle)
- Archive-name: libhoward/part06
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 6 (of 9)."
- # Contents: ma2d.c ma2i.c ma2l.c malf0.c malf1.c mk-cc-lims.b mk-reg.b
- # mopenp.3 mra2d.c mra2i.c mra2l.c mra2u.c mra2ul.c prefxi.c usage.h
- # userfn.c
- # Wrapped by howard@hasse on Mon Sep 25 07:08:11 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'ma2d.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ma2d.c'\"
- else
- echo shar: Extracting \"'ma2d.c'\" \(3062 characters\)
- sed "s/^X//" >'ma2d.c' <<'END_OF_FILE'
- X/*
- X * ma2d - convert Ada-syntax real literal to double, handle errors
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: ma2d.c,v 1.6 89/08/12 08:58:22 howard Exp $");
- X
- X#include <errno.h>
- X#include <float.h>
- X#include <limits.h>
- X#include <string.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC double ma2d (str, lim, synok, fn, end)
- X bStrT str; /* Input string.*/
- X bStrT lim; /* Don't pass this.*/
- X boolT synok; /* Accept non-fatal syntax errors.*/
- X bStrT fn; /* Field name, for error messages.*/
- XR2 bStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Call a2d(). Switch on return code.
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- X bStrT ep; /* a2d() stores pointer to end of string here.*/
- X double d; /* a2d() stores its result here.*/
- XR3 int p1; /* Precision for printing str (up to syntax error).*/
- XR4 int p2; /* Precision for printing str (after syntax error).*/
- XR1 int s; /* Return code.*/
- X
- Xs = a2d (str, lim, synok, &d, &ep);
- Xswitch (s)
- X {
- X case SUCCESS:
- X break;
- X case EDOM:
- X p1 = ep - str;
- X p2 = ((NULBSTR == lim) ? strlen (str) : lim - str) - p1;
- X malf1 ("%s [%.*s|%.*s]: syntax error", fn, p1, str, p2, ep);
- X break;
- X case ERANGE:
- X p1 = ((NULBSTR == lim) ? INT_MAX : lim - str);
- X malf1 ("%s [%.*s] not in range [%G, %G]",
- X fn, p1, str, -DBL_MAX, DBL_MAX);
- X break;
- X case EINVAL:
- X if (NULBSTR == str) malf1 ("ma2d: null string argument");
- X /* Falls through.*/
- X default:
- X malf1 ("ma2d: impossible error %d", s);
- X }
- Xif (((bStrT *) NULL) != end) *end = ep;
- Xreturn (d);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: ma2d.c,v 1.6 89/08/12 08:58:22 howard Exp $");
- XUSAGE ("real-numeric-literal [limit]");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* Points to end of string.*/
- Xdouble d; /* Returned by ma2d().*/
- X
- Xif (argc < 2) usage();
- Xd = ma2d (argv[1], (2 == argc) ? NULBSTR : &argv[1][atoi (argv[2])], FALSE,
- X S("real-numeric-literal"), &end);
- XPRINTF ("%G\t%s\n", d, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 3062 -ne `wc -c <'ma2d.c'`; then
- echo shar: \"'ma2d.c'\" unpacked with wrong size!
- fi
- # end of 'ma2d.c'
- fi
- if test -f 'ma2i.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ma2i.c'\"
- else
- echo shar: Extracting \"'ma2i.c'\" \(3052 characters\)
- sed "s/^X//" >'ma2i.c' <<'END_OF_FILE'
- X/*
- X * ma2i - convert Ada-syntax integer literal to int, handle errors
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: ma2i.c,v 1.6 89/08/12 09:10:44 howard Exp $");
- X
- X#include <errno.h>
- X#include <limits.h>
- X#include <string.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC int ma2i (str, lim, synok, fn, end)
- X bStrT str; /* Input string.*/
- X bStrT lim; /* Don't pass this.*/
- X boolT synok; /* Accept non-fatal syntax errors.*/
- X bStrT fn; /* Field name, for error messages.*/
- XR2 bStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Call a2i() then switch on return code.
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- X bStrT ep; /* a2i() stores pointer to end of string here.*/
- X int i; /* a2i() stores its result here.*/
- XR3 int p1; /* Precision for printing str (up to syntax error).*/
- XR4 int p2; /* Precision for printing str (after syntax error).*/
- XR1 int s; /* Return code.*/
- X
- Xs = a2i (str, lim, synok, &i, &ep);
- Xswitch (s)
- X {
- X case SUCCESS:
- X break;
- X case EDOM:
- X p1 = ep - str;
- X p2 = ((NULBSTR == lim) ? strlen (str) : lim - str) - p1;
- X malf1 ("%s [%.*s|%.*s]: syntax error", fn, p1, str, p2, ep);
- X break;
- X case ERANGE:
- X p1 = ((NULBSTR == lim) ? INT_MAX : lim - str);
- X malf1 ("%s [%.*s] not in range [%d, %d]", fn, p1, str, INT_MIN, INT_MAX);
- X break;
- X case EINVAL:
- X if (NULBSTR == str) malf1 ("ma2i: null string argument");
- X /* Falls through.*/
- X default:
- X malf1 ("ma2i: impossible error %d", s);
- X }
- Xif (((bStrT *) NULL) != end) *end = ep;
- Xreturn (i);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: ma2i.c,v 1.6 89/08/12 09:10:44 howard Exp $");
- XUSAGE ("integer-numeric-literal [limit]");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* Points to end of string.*/
- Xint i; /* Returned by ma2i().*/
- X
- Xif (argc < 2) usage();
- Xi = ma2i (argv[1], (2 == argc) ? NULBSTR : &argv[1][atoi (argv[2])], FALSE,
- X S("integer-numeric-literal"), &end);
- XPRINTF ("8#%o#\t10#%d#\t16#%X#\t%s\n", i, i, i, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 3052 -ne `wc -c <'ma2i.c'`; then
- echo shar: \"'ma2i.c'\" unpacked with wrong size!
- fi
- # end of 'ma2i.c'
- fi
- if test -f 'ma2l.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ma2l.c'\"
- else
- echo shar: Extracting \"'ma2l.c'\" \(3037 characters\)
- sed "s/^X//" >'ma2l.c' <<'END_OF_FILE'
- X/*
- X * ma2l - convert Ada-syntax integer literal to long, handle errors
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: ma2l.c,v 1.3 89/08/12 09:22:39 howard Exp $");
- X
- X#include <errno.h>
- X#include <limits.h>
- X#include <string.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC long ma2l (str, lim, synok, fn, end)
- X bStrT str; /* Input string.*/
- X bStrT lim; /* Don't pass this.*/
- X boolT synok; /* Accept non-fatal syntax errors.*/
- X bStrT fn; /* Field name, for error messages.*/
- XR2 bStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X *
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- X bStrT ep; /* a2l() stores pointer to end of string here.*/
- X long l; /* a2l() stores its result here.*/
- XR3 int p1; /* Precision for printing str (up to syntax error).*/
- XR4 int p2; /* Precision for printing str (after syntax error).*/
- XR1 int s; /* Return code.*/
- X
- Xs = a2l (str, lim, synok, &l, &ep);
- Xswitch (s)
- X {
- X case SUCCESS:
- X break;
- X case EDOM:
- X p1 = ep - str;
- X p2 = ((NULBSTR == lim) ? strlen (str) : lim - str) - p1;
- X malf1 ("%s [%.*s|%.*s]: syntax error", fn, p1, str, p2, ep);
- X break;
- X case ERANGE:
- X p1 = ((NULBSTR == lim) ? INT_MAX : lim - str);
- X malf1 ("%s [%.*s] not in range [%ld, %ld]",
- X fn, p1, str, LONG_MIN, LONG_MAX);
- X break;
- X case EINVAL:
- X if (NULBSTR == str) malf1 ("ma2l: null string argument");
- X /* Falls through.*/
- X default:
- X malf1 ("ma2l: impossible error %d", s);
- X }
- Xif (((bStrT *) NULL) != end) *end = ep;
- Xreturn (l);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: ma2l.c,v 1.3 89/08/12 09:22:39 howard Exp $");
- XUSAGE ("integer-numeric-literal [limit]");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* Points to end of string.*/
- Xlong l; /* Returned by ma2l().*/
- X
- Xif (argc < 2) usage();
- Xl = ma2l (argv[1], (2 == argc) ? NULBSTR : &argv[1][atoi (argv[2])], FALSE,
- X S("integer-numeric-literal"), &end);
- XPRINTF ("8#%lo#\t10#%ld#\t16#%lX#\t%s\n", l, l, l, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 3037 -ne `wc -c <'ma2l.c'`; then
- echo shar: \"'ma2l.c'\" unpacked with wrong size!
- fi
- # end of 'ma2l.c'
- fi
- if test -f 'malf0.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'malf0.c'\"
- else
- echo shar: Extracting \"'malf0.c'\" \(2751 characters\)
- sed "s/^X//" >'malf0.c' <<'END_OF_FILE'
- X/*
- X * malf0 - malf (0, ...)
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: malf0.c,v 1.11 89/08/21 17:50:47 howard Exp $");
- X
- X#include <howard/malf.h>
- X
- X#ifdef NOVPRINTF
- X/*VARARGS1*/
- XPUBLIC void malf0 (a, b, c, d, e, f)
- XcStrT a;
- X{
- Xmalf (0, a, b, c, d, e, f);
- X}
- X#else NOVPRINTF
- X#include <varargs.h>
- X#include <howard/registers.i>
- X
- X/*VARARGS0*/
- XPUBLIC void malf0 (va_alist)
- Xva_dcl
- X
- X/* Function:
- X * malf0 (args...) == malf (0, args...)
- X */
- X{
- Xextern bStrT _progn; /* Version string.*/
- Xextern int errno; /* See intro(2).*/
- Xextern int sys_nerr; /* Maximum value of errno for which a
- X * text entry exists.*/
- Xextern cStrT sys_errlist[]; /* Array of pointers to system error
- X * text, indexed by errno.*/
- Xextern cStrT ctime(); /* (3).*/
- Xextern long time(); /* (3C).*/
- XR1 int se = errno; /* Save errno.*/
- X long ut; /* Current system time.*/
- X va_list args;
- XR2 cStrT a; /* Format string.*/
- X
- Xva_start (args);
- Xa = va_arg (args, cStrT);
- XFFLUSH (stdout);
- XFPUTS ("\nWarning", stderr);
- Xif (isatty (fileno (stderr)))
- X {
- X FPUTS (": ", stderr);
- X putspn();
- X }
- Xelse
- X {
- X ut = time ((long *) NULL);
- X FPRINTF (stderr, " message at %s", ctime (&ut));
- X if (NULBSTR != _progn) FPRINTF (stderr, " from: %s\n ", _progn);
- X }
- X(void) vfprintf (stderr, a, args);
- Xva_end (args);
- XPUTC ('\n', stderr);
- Xif (0 != se)
- X {
- X FPRINTF (stderr, " System message %d", se);
- X if ((0 < se) && (se <= sys_nerr)) FPRINTF (stderr, ": %s", sys_errlist[se]);
- X PUTC ('\n', stderr);
- X }
- XFFLUSH (stderr);
- Xerrno = 0;
- X}
- X#endif NOVPRINTF
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: malf0.c,v 1.11 89/08/21 17:50:47 howard Exp $");
- XUSAGE ("");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- Xextern int errno;
- X
- Xerrno = 10;
- Xmalf0 ("%c %s %d %ld %f", '1', "2", 3, 4L, 5.0);
- X}
- X#endif
- END_OF_FILE
- if test 2751 -ne `wc -c <'malf0.c'`; then
- echo shar: \"'malf0.c'\" unpacked with wrong size!
- fi
- # end of 'malf0.c'
- fi
- if test -f 'malf1.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'malf1.c'\"
- else
- echo shar: Extracting \"'malf1.c'\" \(2766 characters\)
- sed "s/^X//" >'malf1.c' <<'END_OF_FILE'
- X/*
- X * malf1 - malf (1, ...)
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: malf1.c,v 1.8 89/08/21 17:50:50 howard Exp $");
- X
- X#include <howard/malf.h>
- X
- X#ifdef NOVPRINTF
- X/*VARARGS1*/
- XPUBLIC void malf1 (a, b, c, d, e, f)
- XcStrT a;
- X{
- Xmalf (1, a, b, c, d, e, f);
- X}
- X#else NOVPRINTF
- X#include <varargs.h>
- X#include <howard/registers.i>
- X
- X/*VARARGS0*/
- XPUBLIC void malf1 (va_alist)
- Xva_dcl
- X
- X/* Function:
- X * malf1 (args...) == malf (1, args...)
- X */
- X{
- Xextern bStrT _progn; /* Version string.*/
- Xextern int errno; /* See intro(2).*/
- Xextern int sys_nerr; /* Maximum value of errno for which a
- X * text entry exists.*/
- Xextern cStrT sys_errlist[]; /* Array of pointers to system error
- X * text, indexed by errno.*/
- Xextern cStrT ctime(); /* (3).*/
- Xextern long time(); /* (3C).*/
- XR1 int se = errno; /* Save errno.*/
- X long ut; /* Current system time.*/
- X va_list args;
- XR2 cStrT a; /* Format string.*/
- X
- Xva_start (args);
- Xa = va_arg (args, cStrT);
- XFFLUSH (stdout);
- XFPUTS ("\nError", stderr);
- Xif (isatty (fileno (stderr)))
- X {
- X FPUTS (": ", stderr);
- X putspn();
- X }
- Xelse
- X {
- X ut = time ((long *) NULL);
- X FPRINTF (stderr, " message at %s", ctime (&ut));
- X if (NULBSTR != _progn) FPRINTF (stderr, " from: %s\n ", _progn);
- X }
- X(void) vfprintf (stderr, a, args);
- Xva_end (args);
- XPUTC ('\n', stderr);
- Xif (0 != se)
- X {
- X FPRINTF (stderr, " System message %d", se);
- X if ((0 < se) && (se <= sys_nerr)) FPRINTF (stderr, ": %s", sys_errlist[se]);
- X PUTC ('\n', stderr);
- X }
- XFFLUSH (stderr);
- Xif (_debug) abort();
- Xexit (1);
- X}
- X#endif VPRINTF
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: malf1.c,v 1.8 89/08/21 17:50:50 howard Exp $");
- XUSAGE ("");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- Xextern int errno;
- X
- Xerrno = 3;
- Xmalf1 ("%c %s %d %ld %f", '1', "2", 3, 4L, 5.0);
- X}
- X#endif
- END_OF_FILE
- if test 2766 -ne `wc -c <'malf1.c'`; then
- echo shar: \"'malf1.c'\" unpacked with wrong size!
- fi
- # end of 'malf1.c'
- fi
- if test -f 'mk-cc-lims.b' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mk-cc-lims.b'\"
- else
- echo shar: Extracting \"'mk-cc-lims.b'\" \(2539 characters\)
- sed "s/^X//" >'mk-cc-lims.b' <<'END_OF_FILE'
- X
- X# mk-cc-lims - make the cc-lims.i include file for this C compiler
- X#
- X# $Header: mk-cc-lims.b,v 1.6 89/09/21 19:22:19 howard Exp $
- X#
- X# Copyright 1989 Howard Lee Gayle
- X# This file is written in the ISO 8859/1 character set.
- X#
- X# This program is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License version 1,
- X# as published by the Free Software Foundation.
- X#
- X# This program is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with this program; if not, write to the Free Software
- X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X#
- X# Shell variables:
- X# t - temporary file
- X# u - usage string
- X
- XCMDNAME=mk-cc-lims
- Xexport CMDNAME
- Xu='Usage: $CMDNAME c-compiler cc-lims.i'
- Xif [ $# -ne 2 ]
- Xthen
- X echo "$u" 1>&2
- X exit 1
- Xfi
- Xt=lims$$.c
- Xecho '/*' > $2
- Xecho ' * cc-lims.i - C compiler limitations file' >> $2
- Xecho ' *' >> $2
- Xecho ' * This file was generated automatically by:' >> $2
- Xecho ' * $Header: mk-cc-lims.b,v 1.6 89/09/21 19:22:19 howard Exp $' >> $2
- Xecho ' */' >> $2
- Xecho '' >> $2
- Xecho 'main(){extern TYPE x();x(0);}' > $t
- X
- Xif $1 -S -DTYPE='signed char' $t
- Xthen
- X echo '/*#define NOSCHAR 1 /* Comment in if no signed char type.*/' >> $2
- Xelse
- X echo '#define NOSCHAR 1 /* Comment in if no signed char type.*/' >> $2
- Xfi
- X
- Xif $1 -S -DTYPE='unsigned char' $t
- Xthen
- X echo '/*#define NOUCHAR 1 /* Comment in if no unsigned char type.*/' >> $2
- Xelse
- X echo '#define NOUCHAR 1 /* Comment in if no unsigned char type.*/' >> $2
- Xfi
- X
- Xif $1 -S -DTYPE='unsigned long' $t
- Xthen
- X echo '/*#define NOULONG 1 /* Comment in if no unsigned long type.*/' >> $2
- Xelse
- X echo '#define NOULONG 1 /* Comment in if no unsigned long type.*/' >> $2
- Xfi
- X
- Xif $1 -S -DTYPE='unsigned short' $t
- Xthen
- X echo '/*#define NOUSHRT 1 /* Comment in if no unsigned short type.*/' >> $2
- Xelse
- X echo '#define NOUSHRT 1 /* Comment in if no unsigned short type.*/' >> $2
- Xfi
- X
- Xif $1 -S -DTYPE='void' $t
- Xthen
- X echo '/*#define NOVOID 1 /* Comment in if no void type.*/' >> $2
- Xelse
- X echo '#define NOVOID 1 /* Comment in if no void type.*/' >> $2
- Xfi
- X
- Xif $1 -S -DTYPE='void *' $t
- Xthen
- X echo '/*#define NOVOIDP 1 /* Comment in if no void * type.*/' >> $2
- Xelse
- X echo '#define NOVOIDP 1 /* Comment in if no void * type.*/' >> $2
- Xfi
- X
- Xrm $t lims$$.s
- END_OF_FILE
- if test 2539 -ne `wc -c <'mk-cc-lims.b'`; then
- echo shar: \"'mk-cc-lims.b'\" unpacked with wrong size!
- fi
- # end of 'mk-cc-lims.b'
- fi
- if test -f 'mk-reg.b' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mk-reg.b'\"
- else
- echo shar: Extracting \"'mk-reg.b'\" \(2374 characters\)
- sed "s/^X//" >'mk-reg.b' <<'END_OF_FILE'
- X
- X# mk-reg - make registers.i file
- X#
- X# $Header: mk-reg.b,v 1.4 89/09/20 12:21:49 howard Exp $
- X#
- X# Copyright 1989 Howard Lee Gayle
- X# This file is written in the ISO 8859/1 character set.
- X#
- X# This program is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License version 1,
- X# as published by the Free Software Foundation.
- X#
- X# This program is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with this program; if not, write to the Free Software
- X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X#
- X# Shell variables:
- X# a - output string
- X# b - output string
- X# c - .c temporary file
- X# i - loop counter
- X# m - max number of registers
- X# r - number of registers to try
- X# o - old .s file
- X# s - .s file
- X# u - usage string
- X
- XCMDNAME=mk-reg
- Xexport CMDNAME
- Xu="Usage: $CMDNAME c-compiler registers.i"
- Xc=reg$$.c
- Xm=32
- Xo=reg$$.sO
- Xr=0
- Xs=reg$$.s
- Xif [ $# -ne 2 ]
- Xthen
- X echo "$u" 1>&2
- X exit 1
- Xfi
- Xwhile [ $r -le $m ]
- Xdo
- X echo "$r register(s)" 1>&2
- X echo 't(){' > $c
- X i=1
- X while [ $i -le $m ]
- X do
- X if [ $i -le $r ]
- X then
- X a='register '
- X else
- X a=
- X fi
- X if [ 0 -eq `expr $i % 2` ]
- X then
- X b='char *'
- X else
- X b='int '
- X fi
- X echo "$a${b}v$i;" >> $c
- X i=`expr $i + 1`
- X done
- X echo 'return(' >> $c
- X i=1
- X while [ $i -le $m ]
- X do
- X if [ 0 -eq `expr $i % 2` ]
- X then
- X b='*'
- X else
- X b=
- X fi
- X echo "${b}v$i +" >> $c
- X i=`expr $i + 1`
- X done
- X echo '0);}' >> $c
- X $1 -S $c
- X if [ 0 -eq $r ]
- X then
- X mv -f $s $o
- X elif cmp -s $s $o
- X then
- X break
- X else
- X mv -f $s $o
- X fi
- X r=`expr $r + 1`
- Xdone
- Xecho '/*' > $2
- Xecho ' * registers.i - portable allocation of register variables' >> $2
- Xecho ' *' >> $2
- Xecho ' * This file was generated automatically by:' >> $2
- Xecho ' * $Header: mk-reg.b,v 1.4 89/09/20 12:21:49 howard Exp $' >> $2
- Xecho ' */' >> $2
- Xecho '' >> $2
- Xi=1
- Xwhile [ $i -le $m ]
- Xdo
- X if [ $i -lt $r ]
- X then
- X a=' register'
- X else
- X a=
- X fi
- X echo "#define R$i$a" >> $2
- X i=`expr $i + 1`
- Xdone
- Xrm -f $c $o $s
- END_OF_FILE
- if test 2374 -ne `wc -c <'mk-reg.b'`; then
- echo shar: \"'mk-reg.b'\" unpacked with wrong size!
- fi
- # end of 'mk-reg.b'
- fi
- if test -f 'mopenp.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mopenp.3'\"
- else
- echo shar: Extracting \"'mopenp.3'\" \(2401 characters\)
- sed "s/^X//" >'mopenp.3' <<'END_OF_FILE'
- X.\" $Header: mopenp.3,v 1.1 89/08/13 16:20:15 howard Exp $
- X.TH MOPENP "3 -lhoward" "$Revision: 1.1 $" "Howard\'s C library" "Howard\'s C library"
- X.SH NAME
- Xmopenp \- search path for file and open it
- X.SH SYNOPSIS
- X.nf
- X.BR "#include <" stdio.h ">"
- X.BR "#include <" howard/port.h ">"
- X.BR "#include <" howard/malf.h ">"
- X.fi
- X.LP
- XstreamT mopenp (
- X.IR path ,
- X.IR separator ,
- X.IR simple ,
- X.IR suffix ,
- X.IR mode ,
- X.IR buffer ,
- X.IR length )
- X.nf
- X.RI "bStrT " path ;
- X.RI "rcharT " separator ;
- X.RI "bStrT " simple ;
- X.RI "bStrT " suffix ;
- X.RI "bStrT " mode ;
- X.RI "bStrT " buffer ;
- X.BI "unsigned " length;
- X.SH COPYRIGHT
- XCopyright \(co 1989 Howard Lee Gayle
- X.SH DESCRIPTION
- X.I Mopenp
- Xsearches the directory search path in
- X.I path
- Xfor a file named
- X.I simple
- Xwith suffix
- X.IR suffix ,
- Xopens the file by calling
- X.IR fopen (3S)
- Xwith the given
- X.IR mode ,
- Xthen returns the stream.
- XThe directories in the search path are separated by the
- X.I separator
- Xcharacter.
- XEach directory may end in "/", but need not do so.
- XThe full file name is assembled in the area to which
- X.I buffer
- Xpoints.
- X.I Length
- Xgives the number of bytes in this area.
- X.SH RETURNS
- XOn success, the stream corresponding to the opened file.
- XOn error,
- X.I mopenp
- Xcalls
- X.IR malf1 ,
- Xso there is no return.
- X.SH EXAMPLE
- XThis very contrived example searches first /usr/local/include,
- Xthen /usr/include for stdio.h, and opens it for reading.
- X.nf
- X streamT is;
- X byteT fnb[MFILE];
- X is = mopenp (S("/usr/local/include:/usr/include"), ':',
- X S("stdio"), S(".h"), S("r"), fnb, MFILE);
- X.fi
- X.SH "SEE ALSO"
- X.IR fopen (3S),
- X.IR malf "(3 -lhoward)."
- X.SH LICENSE
- XThis program is free software; you can redistribute it and/or modify
- Xit under the terms of the GNU General Public License version 1,
- Xas published by the Free Software Foundation.
- X.PP
- XThis program is distributed in the hope that it will be useful,
- Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- XGNU General Public License for more details.
- X.PP
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; if not, write to the Free Software
- XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X.SH AUTHOR
- XHoward Gayle,
- XTN/ETX/T/BG,
- XEricsson Telecom AB,
- XS-126 25 Stockholm,
- XSweden,
- Xhoward@ericsson.se,
- Xuunet!ericsson.se!howard,
- XPhone: +46 8 719 5565,
- XFAX: +46 8 719 9598,
- XTelex: 14910 ERIC S
- END_OF_FILE
- if test 2401 -ne `wc -c <'mopenp.3'`; then
- echo shar: \"'mopenp.3'\" unpacked with wrong size!
- fi
- # end of 'mopenp.3'
- fi
- if test -f 'mra2d.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mra2d.c'\"
- else
- echo shar: Extracting \"'mra2d.c'\" \(2457 characters\)
- sed "s/^X//" >'mra2d.c' <<'END_OF_FILE'
- X/*
- X * mra2d - convert Ada-syntax real literal to double, check range
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: mra2d.c,v 1.5 89/08/12 10:43:12 howard Exp $");
- X
- X#include <limits.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC double mra2d (str, lim, synok, fn, lo, hi, end)
- XbStrT str; /* Input string.*/
- XbStrT lim; /* Don't pass this.*/
- XboolT synok; /* Accept non-fatal syntax errors.*/
- XbStrT fn; /* Field name, for error messages.*/
- Xdouble lo; /* Minimum legal value.*/
- Xdouble hi; /* Maximum legal value.*/
- XbStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Call ma2d() then do a range check.
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- Xdouble d; /* Returned by ma2d().*/
- X
- Xd = ma2d (str, lim, synok, fn, end);
- Xif ((d < lo) || (d > hi))
- X malf1 ("%s [%.*s] not in range [%G, %G]", fn,
- X (NULBSTR == lim) ? INT_MAX : lim - str, str, lo, hi);
- Xreturn (d);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: mra2d.c,v 1.5 89/08/12 10:43:12 howard Exp $");
- XUSAGE ("real-numeric-literal lo hi");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* End of string.*/
- Xdouble d; /* Returned by mra2d().*/
- X
- Xif (4 != argc) usage();
- Xd = mra2d (argv[1], NULBSTR, TRUE, S("real-numeric-literal"),
- X ma2d (argv[2], NULBSTR, FALSE, S("lo"), (bStrT *) NULL),
- X ma2d (argv[3], NULBSTR, FALSE, S("hi"), (bStrT *) NULL),
- X &end);
- XPRINTF ("%G\t%s\n", d, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 2457 -ne `wc -c <'mra2d.c'`; then
- echo shar: \"'mra2d.c'\" unpacked with wrong size!
- fi
- # end of 'mra2d.c'
- fi
- if test -f 'mra2i.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mra2i.c'\"
- else
- echo shar: Extracting \"'mra2i.c'\" \(2470 characters\)
- sed "s/^X//" >'mra2i.c' <<'END_OF_FILE'
- X/*
- X * mra2i - convert Ada-syntax integer literal to int, check range
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: mra2i.c,v 1.5 89/08/13 07:35:40 howard Exp $");
- X
- X#include <limits.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC int mra2i (str, lim, synok, fn, lo, hi, end)
- XbStrT str; /* Input string.*/
- XbStrT lim; /* Don't pass this.*/
- XboolT synok; /* Accept non-fatal syntax errors.*/
- XbStrT fn; /* Field name, for error messages.*/
- Xint lo; /* Minimum legal value.*/
- Xint hi; /* Maximum legal value.*/
- XbStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Call ma2i() then range check.
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- XR1 int i; /* Returned by ma2i().*/
- X
- Xi = ma2i (str, lim, synok, fn, end);
- Xif ((i < lo) || (i > hi))
- X malf1 ("%s [%.*s] not in range [%d, %d]", fn,
- X (NULBSTR == lim) ? INT_MAX : lim - str, str, lo, hi);
- Xreturn (i);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: mra2i.c,v 1.5 89/08/13 07:35:40 howard Exp $");
- XUSAGE ("integer-numeric-literal lo hi");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* End of string.*/
- Xint i; /* Returned by mra2i().*/
- X
- Xif (4 != argc) usage();
- Xi = mra2i (argv[1], NULBSTR, TRUE, S("integer-numeric-literal"),
- X ma2i (argv[2], NULBSTR, FALSE, S("lo"), (bStrT *) NULL),
- X ma2i (argv[3], NULBSTR, FALSE, S("hi"), (bStrT *) NULL),
- X &end);
- XPRINTF ("8#%o#\t10#%d#\t16#%X#\t%s\n", i, i, i, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 2470 -ne `wc -c <'mra2i.c'`; then
- echo shar: \"'mra2i.c'\" unpacked with wrong size!
- fi
- # end of 'mra2i.c'
- fi
- if test -f 'mra2l.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mra2l.c'\"
- else
- echo shar: Extracting \"'mra2l.c'\" \(2476 characters\)
- sed "s/^X//" >'mra2l.c' <<'END_OF_FILE'
- X/*
- X * mra2u - convert Ada-syntax integer literal to long, check range
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: mra2l.c,v 1.2 89/08/13 08:05:51 howard Exp $");
- X
- X#include <limits.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC long mra2l (str, lim, synok, fn, lo, hi, end)
- XbStrT str; /* Input string.*/
- XbStrT lim; /* Don't pass this.*/
- XboolT synok; /* Accept non-fatal syntax errors.*/
- XbStrT fn; /* Field name, for error messages.*/
- Xlong lo; /* Minimum legal value.*/
- Xlong hi; /* Maximum legal value.*/
- XbStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Call ma2l() then range check.
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- Xlong l; /* Returned by ma2l().*/
- X
- Xl = ma2l (str, lim, synok, fn, end);
- Xif ((l < lo) || (l > hi))
- X malf1 ("%s [%.*s] not in range [%ld, %ld]", fn,
- X (NULBSTR == lim) ? INT_MAX : lim - str, str, lo, hi);
- Xreturn (l);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: mra2l.c,v 1.2 89/08/13 08:05:51 howard Exp $");
- XUSAGE ("integer-numeric-literal lo hi");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* End of string.*/
- Xlong l; /* Returned by mra2l().*/
- X
- Xif (4 != argc) usage();
- Xl = mra2l (argv[1], NULBSTR, TRUE, S("integer-numeric-literal"),
- X ma2l (argv[2], NULBSTR, FALSE, S("lo"), (bStrT *) NULL),
- X ma2l (argv[3], NULBSTR, FALSE, S("hi"), (bStrT *) NULL),
- X &end);
- XPRINTF ("8#%lo#\t10#%ld#\t16#%lX#\t%s\n", l, l, l, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 2476 -ne `wc -c <'mra2l.c'`; then
- echo shar: \"'mra2l.c'\" unpacked with wrong size!
- fi
- # end of 'mra2l.c'
- fi
- if test -f 'mra2u.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mra2u.c'\"
- else
- echo shar: Extracting \"'mra2u.c'\" \(2511 characters\)
- sed "s/^X//" >'mra2u.c' <<'END_OF_FILE'
- X/*
- X * mra2u - convert Ada-syntax integer literal to unsigned, check range
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: mra2u.c,v 1.4 89/08/13 07:46:02 howard Exp $");
- X
- X#include <limits.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC unsigned mra2u (str, lim, synok, fn, lo, hi, end)
- XbStrT str; /* Input string.*/
- XbStrT lim; /* Don't pass this.*/
- XboolT synok; /* Accept non-fatal syntax errors.*/
- XbStrT fn; /* Field name, for error messages.*/
- Xunsigned lo; /* Minimum legal value.*/
- Xunsigned hi; /* Maximum legal value.*/
- XbStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Call ma2u() then range check.
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- XR1 unsigned u; /* Returned by ma2u().*/
- X
- Xu = ma2u (str, lim, synok, fn, end);
- Xif ((u < lo) || (u > hi))
- X malf1 ("%s [%.*s] not in range [%u, %u]", fn,
- X (NULBSTR == lim) ? INT_MAX : lim - str, str, lo, hi);
- Xreturn (u);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: mra2u.c,v 1.4 89/08/13 07:46:02 howard Exp $");
- XUSAGE ("integer-numeric-literal lo hi");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* End of string.*/
- Xunsigned u; /* Returned by mra2u().*/
- X
- Xif (4 != argc) usage();
- Xu = mra2u (argv[1], NULBSTR, TRUE, S("integer-numeric-literal"),
- X ma2u (argv[2], NULBSTR, FALSE, S("lo"), (bStrT *) NULL),
- X ma2u (argv[3], NULBSTR, FALSE, S("hi"), (bStrT *) NULL),
- X &end);
- XPRINTF ("8#%o#\t10#%u#\t16#%X#\t%s\n", u, u, u, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 2511 -ne `wc -c <'mra2u.c'`; then
- echo shar: \"'mra2u.c'\" unpacked with wrong size!
- fi
- # end of 'mra2u.c'
- fi
- if test -f 'mra2ul.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mra2ul.c'\"
- else
- echo shar: Extracting \"'mra2ul.c'\" \(2508 characters\)
- sed "s/^X//" >'mra2ul.c' <<'END_OF_FILE'
- X/*
- X * mra2u - convert Ada-syntax integer literal to unsigned long, check range
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: mra2ul.c,v 1.2 89/08/13 08:20:50 howard Exp $");
- X
- X#include <limits.h>
- X#include <howard/a2.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC ulongT mra2ul (str, lim, synok, fn, lo, hi, end)
- XbStrT str; /* Input string.*/
- XbStrT lim; /* Don't pass this.*/
- XboolT synok; /* Accept non-fatal syntax errors.*/
- XbStrT fn; /* Field name, for error messages.*/
- XulongT lo; /* Minimum legal value.*/
- XulongT hi; /* Maximum legal value.*/
- XbStrT *end; /* End pointer stored here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Call ma2ul() then range check.
- X * Returns:
- X *
- X * Notes:
- X *
- X */
- X{
- XulongT l; /* Returned by ma2ul().*/
- X
- Xl = ma2ul (str, lim, synok, fn, end);
- Xif ((l < lo) || (l > hi))
- X malf1 ("%s [%.*s] not in range [%lu, %lu]", fn,
- X (NULBSTR == lim) ? INT_MAX : lim - str, str, lo, hi);
- Xreturn (l);
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: mra2ul.c,v 1.2 89/08/13 08:20:50 howard Exp $");
- XUSAGE ("integer-numeric-literal lo hi");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT end; /* End of string.*/
- XulongT l; /* Returned by mra2ul().*/
- X
- Xif (4 != argc) usage();
- Xl = mra2ul (argv[1], NULBSTR, TRUE, S("integer-numeric-literal"),
- X ma2ul (argv[2], NULBSTR, FALSE, S("lo"), (bStrT *) NULL),
- X ma2ul (argv[3], NULBSTR, FALSE, S("hi"), (bStrT *) NULL),
- X &end);
- XPRINTF ("8#%lo#\t10#%lu#\t16#%lX#\t%s\n", l, l, l, end);
- Xmfflush (stdout, "Standard Output");
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 2508 -ne `wc -c <'mra2ul.c'`; then
- echo shar: \"'mra2ul.c'\" unpacked with wrong size!
- fi
- # end of 'mra2ul.c'
- fi
- if test -f 'prefxi.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'prefxi.c'\"
- else
- echo shar: Extracting \"'prefxi.c'\" \(2330 characters\)
- sed "s/^X//" >'prefxi.c' <<'END_OF_FILE'
- X/*
- X * prefxi - Test if one string is prefix of another. Ignore case.
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: prefxi.c,v 1.1 89/08/19 10:31:17 howard Exp $");
- X
- X#include <ctype.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC bStrT prefxi (p, s)
- XR1 bStrT p; /* The candidate prefix.*/
- XR2 bStrT s; /* The string to test.*/
- X
- X/* Function:
- X * Test if p is a prefix of s.
- X * Algorithm:
- X * Compare the strings character by character.
- X * Returns:
- X * If p is a prefix of s, a pointer to the character in s
- X * just after the last character of the prefix.
- X * If p is not a prefix of s, NULBSTR.
- X * Notes:
- X *
- X */
- X{
- XR3 rcharT a; /* Current character from p.*/
- XR4 rcharT b; /* Current character from s.*/
- X
- Xif (NULBSTR == p) malf1 ("prefxi: NULL prefix");
- Xif (NULBSTR == s) malf1 ("prefxi: NULL string");
- Xfor (;;)
- X {
- X a = B(*p);
- X if (EOS == a) return (s);
- X if (isascii (a) && isupper (a)) a = tolower (a);
- X b = B(*s);
- X if (isascii (b) && isupper (b)) b = tolower (b);
- X if (a != b) return (NULBSTR);
- X ++p;
- X ++s;
- X }
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: prefxi.c,v 1.1 89/08/19 10:31:17 howard Exp $");
- XUSAGE ("prefix string");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbStrT r; /* Returned by prefxi().*/
- X
- Xif (3 != argc) usage();
- Xr = prefxi (argv[1], argv[2]);
- Xif (NULBSTR != r) PUTS (r);
- Xmfflush (stdout, S("Standard Output"));
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 2330 -ne `wc -c <'prefxi.c'`; then
- echo shar: \"'prefxi.c'\" unpacked with wrong size!
- fi
- # end of 'prefxi.c'
- fi
- if test -f 'usage.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'usage.h'\"
- else
- echo shar: Extracting \"'usage.h'\" \(268 characters\)
- sed "s/^X//" >'usage.h' <<'END_OF_FILE'
- X/* usage.h - For usage() funtion to print usage string and exit.
- X *
- X * $Header: usage.h,v 1.1 88/08/21 09:02:44 howard Exp $
- X *
- X * Prerequisites: howard/port.h, howard/version.h.
- X */
- X#define USAGE(x) bStrT _usage = ((bStrT)(x)) /* Usage string.*/
- XPUBLIC void usage();
- END_OF_FILE
- if test 268 -ne `wc -c <'usage.h'`; then
- echo shar: \"'usage.h'\" unpacked with wrong size!
- fi
- # end of 'usage.h'
- fi
- if test -f 'userfn.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'userfn.c'\"
- else
- echo shar: Extracting \"'userfn.c'\" \(2371 characters\)
- sed "s/^X//" >'userfn.c' <<'END_OF_FILE'
- X/*
- X * userfn - get user's full name
- X */
- X
- X#ifndef lint
- Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
- X#endif lint
- X
- X/*
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License version 1,
- X * as published by the Free Software Foundation.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <howard/port.h>
- X#include <howard/version.h>
- X
- XMODVER ("@(#)$Header: userfn.c,v 1.2 89/08/20 11:30:07 howard Exp $");
- X
- X#include <pwd.h>
- X#include <howard/malf.h>
- X#include <howard/registers.i>
- X
- XPUBLIC bStrT userfn (fnb)
- XR3 bStrT fnb; /* Store full name here.*/
- X
- X/* Function:
- X *
- X * Algorithm:
- X * Try getlogin() for the login name. Otherwise use the real user ID
- X * to get the password entry. Call getpwf().
- X * Returns:
- X *
- X * Notes:
- X * 1) The idea with getlogin() is that sometimes several lines in
- X * the password file have the same UID. If getlogin() comes
- X * back with a login name, then getpwnam() should return the
- X * corresponding password entry.
- X */
- X{
- XR1 cStrT ln; /* Login name of user.*/
- XR2 struct passwd *pwp; /* Returned by getpwuid(). See getpwent(3).*/
- Xextern cStrT getlogin(); /* (3).*/
- Xextern int getuid(); /* (2).*/
- X
- Xif (NULBSTR == fnb) malf1 ("userfn: no buffer");
- Xln = getlogin();
- Xpwp = ((NULCSTR == ln) ? getpwuid (getuid()) : getpwnam (ln));
- Xreturn ((((struct passwd *) NULL) == pwp) ? NULBSTR : getpwf (pwp, fnb));
- X}
- X
- X#ifdef TEST
- X#include <howard/usage.h>
- X
- XMAINVER ("@(#)$Header: userfn.c,v 1.2 89/08/20 11:30:07 howard Exp $");
- XUSAGE ("");
- X
- XPUBLIC int main (argc, argv)
- Xint argc; /* Number of arguments.*/
- XbStrT *argv; /* Points to array of argument strings.*/
- X{
- XbyteT fnb[1024]; /* Full name buffer.*/
- X
- Xif (1 != argc) usage();
- X(void) userfn (fnb);
- XPUTS (fnb);
- Xmfflush (stdout, S("Standard Output"));
- Xexit (SUCCESS);
- X
- X#ifdef lint
- Xreturn (SUCCESS);
- X#endif
- X}
- X#endif
- END_OF_FILE
- if test 2371 -ne `wc -c <'userfn.c'`; then
- echo shar: \"'userfn.c'\" unpacked with wrong size!
- fi
- # end of 'userfn.c'
- fi
- echo shar: End of archive 6 \(of 9\).
- cp /dev/null ark6isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 9 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-